package vip.fastgo.retroid.android.gamebox.view.activity

import android.os.Bundle
import android.view.View
import vip.fastgo.retroid.android.gamebox.R
import vip.fastgo.retroid.android.gamebox.databinding.ActivityGameBinding
import vip.fastgo.retroid.android.gamebox.utils.MLog
import vip.fastgo.retroid.android.gamebox.view.widget.ABXYView
import vip.fastgo.retroid.android.gamebox.view.widget.DirectionView

class GameActivity : BaseActivity<ActivityGameBinding>(), View.OnClickListener,
    DirectionView.OnPressListener, ABXYView.DoClickListener {

    override fun initBinding(): ActivityGameBinding {
        return ActivityGameBinding.inflate(layoutInflater)
    }

    override fun initView(savedInstanceState: Bundle?) {
        binding.gameStartBtn.setOnClickListener(this)
        binding.gameDirectionView.onPressListener = this
        binding.gameAbxyView.doClickListener = this
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.game_start_btn -> {

            }
            else -> {}
        }
    }

    override fun onPress(view: View, direction: DirectionView.Direction) {
        when (direction) {
            DirectionView.Direction.LEFT -> MLog.i("按下 左")
            DirectionView.Direction.UP -> MLog.i("按下 上")
            DirectionView.Direction.RIGHT -> MLog.i("按下 右")
            DirectionView.Direction.DOWN -> MLog.i("按下 下")
        }
    }

    override fun onLift(view: View, direction: DirectionView.Direction) {
        when (direction) {
            DirectionView.Direction.LEFT -> MLog.i("抬起 左")
            DirectionView.Direction.UP -> MLog.i("抬起 上")
            DirectionView.Direction.RIGHT -> MLog.i("抬起 右")
            DirectionView.Direction.DOWN -> MLog.i("抬起 下")
        }
    }

    override fun doClick(view: View, abxy: ABXYView.ABXY) {
        when (abxy) {
            ABXYView.ABXY.A -> MLog.i("AAAAA")
            ABXYView.ABXY.B -> MLog.i("BBBBB")
            ABXYView.ABXY.X -> MLog.i("XXXXX")
            ABXYView.ABXY.Y -> MLog.i("YYYYY")
        }
    }
}